




/*
*************************************************************************
*西瑞克斯研发管理系统
*版 本: 1.0   
*日 期：03/05/2012    
*作 者： 王浩 QQ：873987060   
*************************************************************************   
*/ 
package com.application.yfsmsrecord.struts.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.manager.commons.config.ConfigFactory;
import com.manager.commons.page.PageBean;
import com.manager.commons.RandomKey;
import com.manager.commons.CommonUtil;
import com.application.yfsmsrecord.entity.YfSmsrecord;
import com.application.yfsmsrecord.struts.form.YfSmsrecordForm;
import com.application.yfsmsrecord.service.YfSmsrecordService;
import com.application.yfsmsrecord.commons.Constants;
 /**
 * 
 * Description:YfSmsrecordAction<br />
 * 
 * Version:V0.1<br />
 * 
 * Author: 王浩 QQ：873987060    <br />
 * 
 * History: <br />
 * 
 * 03/05/2012 
 * 
 */
public class YfSmsrecordAction extends DispatchAction
{
       
       /**
	 * Service层实例
	 */
	private YfSmsrecordService yfSmsrecordService;

	/**
	 * 日志
	 */
	private Logger log = Logger.getLogger(this.getClass());

	/**
	 * 实体对象
	 */
        private YfSmsrecord yfSmsrecord;


        /**
	 * 采用partialList方式分页程序
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public ActionForward getYfSmsrecordPartialList(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		log.debug("searchYfSmsrecord" + "开始");
		YfSmsrecordForm yfSmsrecord = (YfSmsrecordForm)form;
		// 统计总记录数的sql语句
		int resultSize = 0;
		// 初始化pageBean供分页所用
		PageBean pageBean = null;
		// 取得当前页list数据
		List yfSmsrecordList = null;
		resultSize = yfSmsrecordService.getAllCountYfSmsrecord(yfSmsrecord);
		pageBean = PageBean.getPageBean("yfSmsrecordTab", resultSize,request);
		yfSmsrecordList = yfSmsrecordService.searchYfSmsrecord(yfSmsrecord,pageBean);
		request.setAttribute("yfSmsrecordList", yfSmsrecordList);

		log.debug("searchYfSmsrecord" + "结束");

		return mapping.findForward(Constants.SUCCESS);
	}

        /**
	 * 到达新增页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toAddYfSmsrecord(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toAddYfSmsrecords");
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 增加
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward addYfSmsrecord(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("addYfSmsrecords");
		YfSmsrecord yfSmsrecord = this.getYfSmsrecord(form);
     
		 yfSmsrecord.setCreateDate(new Date());

		this.yfSmsrecordService.insertObject(yfSmsrecord);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 删除
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward deleteYfSmsrecord(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("deleteYfSmsrecords");
		YfSmsrecordForm yfSmsrecordForm = (YfSmsrecordForm) form;
		this.yfSmsrecordService.deleteYfSmsrecords(yfSmsrecordForm);
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 到达更新页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toUpdateYfSmsrecord(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toUpdateYfSmsrecords");

		YfSmsrecord yfSmsrecord = this.getYfSmsrecord(form);
		yfSmsrecord = this.yfSmsrecordService.getYfSmsrecord(yfSmsrecord);
		request.setAttribute(Constants.YFSMSRECORD, yfSmsrecord);
		return mapping.findForward(Constants.SUCCESS);
	}

        
	/**
	 * 更新
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward updateYfSmsrecord(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("updateYfSmsrecords");
		YfSmsrecord yfSmsrecord = this.getYfSmsrecord(form);
		 yfSmsrecord.setCreateDate(new Date());
		this.yfSmsrecordService.updateObject(yfSmsrecord);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 查看页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward viewYfSmsrecord(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		log.debug("viewYfSmsrecord");

		YfSmsrecord yfSmsrecord = this.getYfSmsrecord(form);
		yfSmsrecord = this.yfSmsrecordService.getYfSmsrecord(yfSmsrecord);
		request.setAttribute(Constants.YFSMSRECORD, yfSmsrecord);
		return mapping.findForward(Constants.SUCCESS);
	}

	// get--set
	/**
	 * @return the YfSmsrecordService
	 */
	public YfSmsrecordService getYfSmsrecordService() {
		return this.yfSmsrecordService;
	}

	/**
	 * @param YfSmsrecordService
	 *  the YfSmsrecordService to set
	 */
	public void setYfSmsrecordService(YfSmsrecordService yfSmsrecordService) {
		this.yfSmsrecordService = yfSmsrecordService;
	}

	/**
	 * 获取YfSmsrecord实体
	 * @param ActionForm
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 * @return the YfSmsrecord
	 */
	public YfSmsrecord getYfSmsrecord(ActionForm form) throws IllegalAccessException, InvocationTargetException {
		YfSmsrecordForm yfSmsrecordForm = (YfSmsrecordForm) form;
		yfSmsrecord = new YfSmsrecord();
		BeanUtils.copyProperties(yfSmsrecord, yfSmsrecordForm);
		return yfSmsrecord;
	}
    
        public void setYfSmsrecord(YfSmsrecord yfSmsrecord) {
		this.yfSmsrecord = yfSmsrecord;
	}

}
